//
//  SEHospitalDetailServiceCell.swift
//  SmartEyeForPatient
//
//  Created by qdsg on 2021/4/6.
//

import UIKit
enum SEHospitalDetailServiceCellActionType {
    case registration
    case advisory
    case check
}

protocol SEHospitalDetailServiceCellDelegate: NSObjectProtocol {
    func hospitalDetailServiceCellAction(_ actionType: SEHospitalDetailServiceCellActionType)
}

class SEHospitalDetailServiceCell: UITableViewCell {

    static let className = "SEHospitalDetailServiceCell"
    static let reuseId = className

    @IBOutlet weak var registrationBtn: SEHospitalServiceButton!
    @IBOutlet weak var advisoryBtn: SEHospitalServiceButton!
    @IBOutlet weak var checkBtn: SEHospitalServiceButton!

    @IBAction func registrationBtnAction(_ sender: SEHospitalServiceButton) {
        delegate?.hospitalDetailServiceCellAction(.registration)
    }

    @IBAction func advisoryBtnAction(_ sender: SEHospitalServiceButton) {
        delegate?.hospitalDetailServiceCellAction(.advisory)
    }

    @IBAction func checkBtnBtnAction(_ sender: SEHospitalServiceButton) {
        delegate?.hospitalDetailServiceCellAction(.check)
    }

    weak var delegate: SEHospitalDetailServiceCellDelegate?

    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    func updateCell(_ viewModel: SEHospitalDetailViewModel) {
        registrationBtn.updateServiceButton(with: "预约挂号",
                                            detail: "\(viewModel.model.outpatientCount)位医生可挂号",
                                            isEnabled: viewModel.model.outpatientFlag == 1)
        advisoryBtn.updateServiceButton(with: "线上问诊",
                                        detail: "\(viewModel.model.conversionCount)位医生可咨询",
                                        isEnabled: viewModel.model.conversionFlag == 1)
        checkBtn.updateServiceButton(with: "检查预约",
                                     detail: "\(viewModel.model.checkCount)项检查可预约",
                                     isEnabled: viewModel.model.checkFlag == 1)
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
}
